package xyz.coolcsm.security.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import xyz.coolcsm.security.entity.SysRequestPathPermissionRelation;
import xyz.coolcsm.security.mapper.SysRequestPathPermissionRelationMapper;
import xyz.coolcsm.security.service.SysRequestPathPermissionRelationService;

import java.util.List;
/**
 * @author 什锦
 * @since 2021-06-1
 */
@Service
public class SysRequestPathPermissionRelationServiceImpl implements SysRequestPathPermissionRelationService {

    @Autowired
    private SysRequestPathPermissionRelationMapper sysRequestPathPermissionRelationMapper;
    @Override
    public SysRequestPathPermissionRelation queryById(Integer id) {
        return sysRequestPathPermissionRelationMapper.selectById(id);
    }

    @Override
    public List<SysRequestPathPermissionRelation> queryAllByLimit(int offset, int limit) {
        Page<SysRequestPathPermissionRelation> page = new Page<>(offset, limit);
        Page<SysRequestPathPermissionRelation> result = sysRequestPathPermissionRelationMapper.selectPage(page, null);
        return result.getRecords();
    }

    @Override
    public SysRequestPathPermissionRelation insert(SysRequestPathPermissionRelation sysRequestPathPermissionRelation) {
        sysRequestPathPermissionRelationMapper.updateById(sysRequestPathPermissionRelation);
        return sysRequestPathPermissionRelation;
    }

    @Override
    public SysRequestPathPermissionRelation update(SysRequestPathPermissionRelation sysRequestPathPermissionRelation) {
        sysRequestPathPermissionRelationMapper.updateById(sysRequestPathPermissionRelation);
        return sysRequestPathPermissionRelation;
    }

    @Override
    public boolean deleteById(Integer id) {
        return sysRequestPathPermissionRelationMapper.deleteById(id)>0;
    }
}
